<template>
  <!-- <el-dialog title="撤销" :visible.sync="show" width="500px" v-bind="$attrs" v-on="$listeners" @close="handleCancel"> -->
    <a-modal title="撤销" :visible.sync="show" width="500px" :confirm-loading="loading" @ok="handleConfirm" @cancel="handleCancel">
    <el-form v-loading="loading" ref="formRef" :model="formValue">
      <el-form-item prop="comments">
        <el-input type="textarea" v-model="formValue.comments" placeholder="请输入撤销原因"  rows="4"  show-word-limit />
      </el-form-item>
    </el-form>
   
  </a-modal>
</template>

<script>
 import {
    uploadAction,
    httpAction
  } from '@/api/manage'
export default {
  name: 'RevokeModal',
  props: {
    // 是否显示
    visible: {
      type: Boolean,
      default: false
    },
  },
  data() {
    return {
      loading: false,
      formValue: {
        comments: ''
      },
      show:false,
      processInfo:{},
      url:{
        revoke:'workspace/revoke',
      },
      validatorRules:{
        comments:[{ required:true,message:'请输入撤销原因' }],
      },
    }
  },
  // computed: {
  //   show: {
  //     get() {
  //       return this.visible
  //     },
  //     set(visible) {
  //       this.$emit('update:visible', visible)
  //     }
  //   }
  // },
  methods: {
    showModal(record){
      this.processInfo = record
      this.formValue={
        comments: ''
      }
      this.show = true
    },
    // 确认操作
    handleConfirm() {
      this.$refs.formRef.validate(valid => {
        if(!valid) return;
        const params = {
          ...this.processInfo,
          ...this.formValue,
        }
        this.loading = true
        httpAction(this.url.revoke,params,'post')
          .then((res)=>{
            if(res.success){
              this.$message.success(res.message)
              this.handleCancel()
              this.$emit('ok','revoke')
            }else{
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.loading = false
          })
      })
    },
    // 取消操作
    handleCancel() {
      this.$refs.formRef.resetFields();
      this.show = false;
    }
  }
}
</script>
